package org.kazuhiko.rpg.server.util;

import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;

import org.slf4j.LoggerFactory;

import org.slf4j.Logger;

public class Util
{
	private static final Logger logger = LoggerFactory.getLogger( Util.class );
	
	public static ImageIcon createImageIcon( String path )
	{
		URL imgURL = Util.class.getResource( path );
		if( imgURL != null )
		{
			return new ImageIcon( imgURL );
		}
		else
		{
			logger.error( "Can't find image: <" + path + ">" );
			return null;
		}
	}
	
	public static boolean checkOS( OS_Type type )
	{
		String os = System.getProperty( "os.name" ).toLowerCase();
		
		return ( os.indexOf( type.getValue() ) >= 0 );
	}
	
	public static String getDate( String format )
	{
		DateFormat dateFormat = new SimpleDateFormat( format );
		Date date = new Date();
		
		return dateFormat.format( date );
	}
}
